﻿@model string
@{
    string propertyName = ViewData.ModelMetadata.PropertyName;

    IEnumerable<CSF.MultiLang.Data.LangDef> langDefs = ViewBag.LangDefs;
    List<CSF.MultiLang.Data.LangTextContent> texts = (List<CSF.MultiLang.Data.LangTextContent>)ViewData[propertyName + "Texts"];
    
    int i = -1;
}
@Html.TextBox("", Model)
<a id="@(propertyName)Anchor" href="#@(propertyName)Container">Edit</a>
    <div style="display:none">
     <div id="@(propertyName)Container">
        <table cellpadding="1" cellspacing="1" border="0" style="width: 40em">
            <thead>
                <tr>
                    <th>Language</th>
                    <th>Text</th>
                </tr>
            </thead>
            <tbody>
            @foreach (var lang in langDefs)
            {
                if (i == -1)
                {
                <tr>
                    <td align="center"><label>@lang.LangName</label></td>
                    <td align="center"><input id="@(propertyName)Default" type="text" readonly="readonly" value="@Model" style="width: 30em" /> </td>
                </tr>
                }
                else
                {
                    CSF.MultiLang.Data.LangTextContent text = ((texts != null)?texts.FirstOrDefault(p=>p.LangId==lang.Id):null);
                <tr>
                    <td align="center">
                        <input name="@(propertyName)s[@(i)].Id" type="hidden" value="@(text != null ? text.Id : 0)" />
                        <input name="@(propertyName)s[@(i)].LangId" type="hidden" value="@lang.Id" /><label>@lang.LangName</label>
                    </td>
                    <td align="center"><input name="@(propertyName)s[@(i)].Content" type="text" value="@(text!=null?text.Content:null)" style="width: 30em" /></td>
                </tr>
                }
                i++;
            }
            </tbody>
        </table>
     </div>
</div>
<script language="javascript" type="text/javascript">
    $("#@(propertyName)Anchor").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'onStart': function () {
            $('#@(propertyName)Default').val($('#@(propertyName)').val());
        }
    });
</script>